<div class="wrapper clearfix">
	
	<?php $this->load->view('ucenter/sidebar');?>
	
	<div class="content">
		
		<h3>修改个人信息</h3>
		<form action="" method="post" id="mySetting">
		<?php foreach($user as $value): ?>
		
		<div class="form-group first">
			
			<label for="">登录邮箱</label>
			<input type="text" name="email" id="email" class="form-control" disabled="disabled" value="<?php echo $value->user_email; ?>" />
			
		</div>
		<div class="form-group first">
			
			<label for="">昵&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称</label>
			<input type="text" name="nickname" id="nickname" class="form-control" value="<?php echo $value->user_nickname; ?>" />
			
		</div>
		
		
		<div class="form-group">
			
			<label for=""></label>
			<input type="button" name="submitSetting" id="submitSetting" class="btn btn-primary" value="保 存" />
			
		</div>
		<?php endforeach; ?>
		</form>
	</div><!-- content -->


</div>

<script src="<?php echo base_url("static/javascript/zyben.js"); ?>"></script>

<script>
//当控件获取焦点时候，则去除错误提示
$("input").focus(function(){
	
	$(this).popover('destroy');
	$(this).parent().removeClass('has-error');
});

function showErrorMessage(id,message){
	$("#nickname").popover('destroy');
	$("#nickname").parent().removeClass('has-error');
	
	$(id).parent().addClass('has-error');
	$(id).attr('data-content',message);
	$(id).attr('data-placement','right');
	$(id).attr('data-html','true');
	$(id).popover('show');
	$('#register').button('reset');
	
}
$("#submitSetting").click(function(){

	$("#nickname").popover('destroy');
	$("#nickname").parent().removeClass('has-error');
	
	if(!checkInput("#nickname",1,10,"昵称")) return false;

	$.ajax({
		url:"<?php echo base_url('ucenter/SettingAct'); ?>",
		type:"post",
		dataType:"json",
		data:$("#mySetting").serialize(),
		success:function(e){
			if(e.status=='10000'){
				
				new jBox('Notice', {content:"修改成功",position:{x:"center",y:"center"},color:"green" });
				$("#topNickname").html($("#nickname").val());
				
			}else if(e.status=='10008'){
				showErrorMessage("#nickname","昵称不能为空");
			}else if(e.status == '10009'){
				showErrorMessage("#nickname","该昵称太抢手啦，已经被使用了");
			}else if(e.status == '10010'){
				showErrorMessage("#nickname","昵称格式仅支持汉字，数字，英文，下划线");
			}
			
		}
	});
});

</script>
